import 'package:boss/models/printer.dart';
import 'package:boss/ui/widget/radioList/model/radio_item_data.dart';
import 'package:boss/ui/widget/radioList/radio_list.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'printer_provider.dart';

class PrinterList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<PrinterProvider>(
      builder: (context, printerProvider, _){
        return RadioList<Printer>(
          items: printerProvider.printers.map((item) => RadioItemData(
            title: item.printerName,
            value: item,
          )).toList(),
          value: printerProvider.selectedPrinters,
          isMultiple: true,
          onChanged: (printers) {
            printerProvider.setSelectedPrinter(printers);
          },
        );
      },
    );
  }
}
